<template>
  <div class="img" :imgList = 'imgList' >
    <ul >
      <li v-for="item in imgList">
        <img :src="item.src" :alt="item.id">
      </li>
    </ul>
    <div class="fixed"></div>
      <!-- <img :src="item.src" alt=""> -->
  </div>
</template>

<script setup>
import { reactive } from '@vue/reactivity';
import { onMounted } from '@vue/runtime-core';
import axios from 'axios';
let component_name = '图片列表'
let imgList = reactive([]);
axios.get('http://localhost:3000/imglist').then(response => {
  console.log(response);
  imgList.push(...response.data.data)
    // tableData.push(...response.data.data)
  }).catch(error => {
    console.log(error)
  })
onMounted(() => {
  console.log(document.body.offsetHeight);
  window.addEventListener('scroll', function () {
    if (this.window.scrollY > 0) {
      document.querySelector('.fixed').style.opacity = 0;
    document.querySelector('.fixed').style.top = 0;
    } else {
      document.querySelector('.fixed').style.opacity = 1;
    document.querySelector('.fixed').style.top = 0;
    } 
    
    
  })
})
</script>

<style lang="scss">
.img{
  width: 80%;
  margin: 71px auto;
  ul{
    display: flex;
    justify-content: space-evenly;
    flex-wrap: wrap;
    background: gainsboro;
    padding-top: 33px;
    li{
      width: 15%;
    padding: 10px;
    background: #fff;
    border-radius: 10px;
    margin-bottom: 10px;
      img{
        display: block;
        width: 100%;
        height: 150px;
        border-radius: 10px;
      }
    }
  }
  .fixed{
    width: 100vw;
    height: 70px;
    position: fixed;
    background: hotpink;
    left: 0;
    top: 0;
    opacity: 1;
    transition: all .7s;
  }
}


</style>